<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"    
  	xmlns:cc="http://java.sun.com/jsf/composite"
  	xmlns:h="http://java.sun.com/jsf/html"
  	xmlns:p="http://primefaces.org/ui"
  	xmlns:f="http://java.sun.com/jsf/core"
  	xmlns:ui="http://java.sun.com/jsf/facelets">

	<!-- INTERFACE -->
	<cc:interface> 	 
    	<cc:attribute name="bill" />  
    	<cc:attribute name="duplicate" />
    	<cc:attribute name="hosCopy" />   	 
    	<cc:attribute name="showProfessional" />
	</cc:interface>

	<!-- IMPLEMENTATION -->
	<cc:implementation>
    	<h:outputStylesheet library="css" name="printing.css" />
    	<div>
        	<p:panel   id="gpBillPreview"  style="margin: auto; padding: 0px; font-size: 14px!important;" >
            	<div class="a4bill" >


                	<table class="headingPrinting" >
                    	<tr>
                        	<td colspan="4">
                            	<h:outputLabel class="mark" value="**Original Bill**"
                                           	rendered="#{cc.attrs.duplicate ne true and cc.attrs.hosCopy ne true}"/>
                        	</td>
                    	</tr>
                    	<tr>
                        	<td colspan="4"><h:outputLabel class="mark" value="**Hospital Bill**Duplicate Bill**" rendered="#{cc.attrs.duplicate eq true}"/></td>
                    	</tr>
                    	<tr>
                        	<td colspan="4"><h:outputLabel class="mark" value="**Hospital Bill**Original Bill**" rendered="#{cc.attrs.hosCopy eq true}"/></td>
                    	</tr>
                    	<tr>
                        	<td colspan="2">&nbsp;</td>
                    	</tr>
                	</table>
                	<table>
                    	<tr >
                        	<td >
                            	<h:outputLabel value="B.H.T NO" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.bhtNo}" />
                        	</td>
                        	<td>
                            	<h:outputLabel value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="BILL NO" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.insId}" />
                        	</td>
                    	</tr>
                    	<tr >
                        	<td >
                            	<h:outputLabel value="Patient Name" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.patient.person.nameWithTitle}" />
                        	</td>                      	 
                    	</tr>
                    	<tr>
                        	<td >
                            	<h:outputLabel value="Address" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td style="max-width: 300px; overflow-wrap: break-word; ">
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.patient.person.address}"/>
                        	</td>
                        	<td>
                            	<h:outputLabel value="" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="Time of Admission" rendered="#{sessionController.userPreference.applicationInstitution ne 'Ruhuna'}"/>
                            	<h:outputLabel value="Date of Admission" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}"/>
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.printingAdmissionTime}" >
                                	<f:convertDateTime pattern="dd MM yyyy h:mm a" rendered="#{sessionController.userPreference.applicationInstitution ne 'Ruhuna'}"/>
                                	<f:convertDateTime pattern="dd MM yyyy" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}"/>
                            	</h:outputLabel>
                        	</td>
                    	</tr>
                    	<tr >
                        	<td >
                            	<h:outputLabel value="Guardian" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.guardian.nameWithTitle}" />
                        	</td>
                        	<td>
                            	<h:outputLabel value="" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="Time of Discharged" rendered="#{sessionController.userPreference.applicationInstitution ne 'Ruhuna'}"/>
                            	<h:outputLabel value="Date of Discharged" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}"/>
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.printingDischargeTime}" >
                                	<f:convertDateTime pattern="dd MM yyyy h:mm a" rendered="#{sessionController.userPreference.applicationInstitution ne 'Ruhuna'}"/>
                                	<f:convertDateTime pattern="dd MM yyyy" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}"/>
                            	</h:outputLabel>
                        	</td>
                    	</tr>                  	 
                    	<tr >
                        	<td>
                            	<h:outputLabel value="Room " />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.currentPatientRoom.printRoomFacilityCharge.room.name}" />
                        	</td>                       	 
                    	</tr> 	 

                	</table>

                	<table class="tbl"  >
                    	<tr style="t">
                        	<td style="text-align: left; font-weight: bold;">
                            	<h:outputLabel value="Discription" />
                        	</td>
                        	<td>
                            	<h:outputLabel value="" />
                        	</td>
                        	<td style="text-align: right; font-weight: bold;">
                            	<h:outputLabel value="Charge (Rs.)" />
                        	</td>
                    	</tr>
                    	<ui:repeat value="#{cc.attrs.bill.billItems}" var="bip">
                        	<h:panelGroup rendered="#{(bip.adjustedValue!=0 and  bip.inwardChargeType ne 'ProfessionalCharge')
                                                  	or
                                                  	(bip.adjustedValue!=0 and cc.attrs.showProfessional eq true and bip.inwardChargeType eq 'ProfessionalCharge')}">
                            	<tr style="width: 100%;"  >
                                	<td style="text-align: left;font-size: 13px!important;">
                                    	<h:outputLabel   value="#{bip.inwardChargeType.label}" style="margin: 4px;" >
                                    	</h:outputLabel>
                                	</td>
                                	<td>
                                    	<h:panelGroup >
                                        	<h:panelGroup rendered="#{!(bip.inwardChargeType eq 'ProfessionalCharge'
                                                                  	and bip.inwardChargeType eq 'RoomCharges' )}">
                                            	&nbsp;
                                        	</h:panelGroup>
                                        	<h:panelGroup rendered="#{bip.inwardChargeType eq 'ProfessionalCharge' }">
                                            	<table>                                        	 
                                                	<ui:repeat value="#{bip.proFees}" var="fe">
                                                    	<h:panelGroup rendered="#{fe.feeAdjusted ne 0
                                                                              	and fe.bill.cancelled eq false
                                                                              	and fe.bill.billClass eq 'class com.divudi.entity.BilledBill'}" style="">
                                                        	<tr>

                                                            	<td style="text-align: left;font-size: 8px!important;">
                                                                	<h:panelGroup>                  	 
                                                                    	#{fe.staff.person.nameWithTitle}
                                                                	</h:panelGroup>
                                                            	</td>
                                                            	<td  style="text-align: right;font-size: 8px!important;">
                                                                	<h:panelGroup>
                                                                    	<h:outputLabel value="#{fe.feeAdjusted}">
                                                                        	<f:convertNumber pattern="#,##0.00" />
                                                                    	</h:outputLabel>
                                                                	</h:panelGroup>
                                                            	</td>
                                                        	</tr>
                                                    	</h:panelGroup>
                                                	</ui:repeat>   
                                            	</table>
                                        	</h:panelGroup>
                                        	<h:panelGroup rendered="sessionController.userPreference.applicationInstitution ne 'Ruhuna'">
                                            	<table>                                          	 
                                                	<ui:repeat value="#{bip.billFees}" var="fe">
                                                    	<h:panelGroup >
                                                        	<tr>
                                                            	<td>
                                                                	<h:outputLabel value="#{fe.referencePatientRoom.name}"   style="text-align: center;font-size: 9px!important;"/>
                                                            	</td>
                                                            	<td>
                                                                	<h:outputLabel value=" || " style="text-align: center;font-size: 9px!important;"/>
                                                            	</td>
                                                            	<td>
                                                                	<h:outputLabel value="#{fe.referencePatientRoom.printAdmittedAt}"  style="text-align: center;font-size: 9px!important;">
                                                                    	<f:convertDateTime pattern="dd/MM/yyyy hh mm a" />
                                                                	</h:outputLabel>
                                                            	</td>
                                                            	<td>
                                                                	<h:outputLabel value=" || " style="text-align: center;font-size: 9px!important;"/>
                                                            	</td>
                                                            	<td >
                                                                	<h:outputLabel  value="#{fe.referencePatientRoom.printDischargeAt}" style="text-align: center;font-size: 9px!important;" >
                                                                    	<f:convertDateTime pattern="dd/MM/yyyy hh mm a" />
                                                                	</h:outputLabel>
                                                            	</td>
                                                            	<td>
                                                                	<h:outputLabel value=" || " style="text-align: center;font-size: 9px!important;"/>
                                                            	</td>
                                                            	<td>

<!--                                                                	<h:outputLabel value="#{fe.referencePatientRoom.adjustedRoomCharge}" style="text-align: center;font-size: 9px!important;" >
                                                                    	<f:convertNumber pattern="#,##0.00" />
                                                                	</h:outputLabel>                                                            	-->
                                                            	</td>
                                                        	</tr>
                                                    	</h:panelGroup>
                                                	</ui:repeat>   
                                            	</table>
                                        	</h:panelGroup>
                                    	</h:panelGroup>                                	 
                                	</td>
                                	<td  style="width: 30%;text-align: right;font-size: 13px!important;">                                   	 
                                    	<h:outputLabel  value="#{bip.adjustedValue}">
                                        	<f:convertNumber pattern="#,##0.00" />
                                    	</h:outputLabel>
                                	</td>
                            	</tr>
                        	</h:panelGroup>
                    	</ui:repeat>


                    	<h:panelGroup>
                        	<!--GRANT TOTAL-->
                        	<tr>
                            	<td>&nbsp;</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;"><h:outputLabel value="-------------------" /></td>
                        	</tr>


                        	<h:panelGroup >                        	 
                            	<tr style="width: 100%;">
                                	<td style="text-align: left; font-size: 13px!important;font-weight: bold!important;">
                                    	<h:outputLabel value="Total"/>
                                	</td>
                                	<td>&nbsp;</td>
                                	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">

                                    	<h:outputLabel rendered="#{cc.attrs.showProfessional}" value="#{cc.attrs.bill.grantTotal}" >
                                        	<f:convertNumber pattern="#,##0.00" />
                                    	</h:outputLabel>  

                                    	<h:outputLabel rendered="#{!cc.attrs.showProfessional}" value="#{cc.attrs.bill.hospitalFee}" >
                                        	<f:convertNumber pattern="#,##0.00" />
                                    	</h:outputLabel>  

                                	</td>
                            	</tr>
                        	</h:panelGroup>                      	 

                    	</h:panelGroup>

                    	<!--DISCOUNT-->
                    	<h:panelGroup >
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}" value="Discount"/>
                            	</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel rendered="#{cc.attrs.bill.discount ne 0.0}"   value="#{cc.attrs.bill.discount}" >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>
                            	</td>
                        	</tr>
                    	</h:panelGroup>

                    	<!--NETTOTAL-->
                    	<h:panelGroup >
                        	<tr>
                            	<td>&nbsp;</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;"><h:outputLabel value="-------------------" /></td>
                        	</tr>
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  value="Net Total"/>
                            	</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel rendered="#{cc.attrs.showProfessional}" value="#{cc.attrs.bill.netTotal}" >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>  

                                	<h:outputLabel rendered="#{!cc.attrs.showProfessional}" value="#{cc.attrs.bill.hospitalFee-cc.attrs.bill.discount}" >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>  

                            	</td>
                        	</tr>

                        	<tr>
                            	<td>&nbsp;</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;"><h:outputLabel value="============"/></td>
                        	</tr>
                    	</h:panelGroup>


<!--                    	<h:panelGroup >
                                                    	PAID AMOUNT
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel   value="Paid By Patient " rendered="#{cc.attrs.bill.paidAmount !=0}"/>
                            	</td>
                            	<td>
                                	<table>
                                    	<ui:repeat value="#{cc.attrs.bill.backwardReferenceBills}" var="b">
                                        	<h:panelGroup  rendered="#{(b.netTotal ne 0 )                                                                  	 
                                                                   	and                                                                   	 
                                                                   	((b.cancelled eq false
                                                                   	and b.billClass eq 'class com.divudi.entity.BilledBill')
                                                                   	or
                                                                   	(b.cancelled eq false
                                                                   	and b.refundedBill eq null
                                                                   	and b.billClass eq 'class com.divudi.entity.RefundBill'))}" >                                       	 
                                            	<tr>
                                                	<td>
                                                    	#{b.insId}
                                                	</td>                                              	 
                                                	<td>
                                                    	<h:outputLabel value="#{b.netTotal}">
                                                        	<f:convertNumber pattern="#,##0.00" />
                                                    	</h:outputLabel>
                                                	</td>
                                            	</tr>
                                        	</h:panelGroup>
                                    	</ui:repeat>
                                	</table>
                            	</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  value="#{cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.paidByCreditCompany}" rendered="#{cc.attrs.bill.paidAmount !=0}" >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>
                            	</td>
                        	</tr>


                    	</h:panelGroup>

                    	<h:panelGroup >
                        	DUE AMOUNT
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel   value="Due Amount" />
                            	</td>
                            	<td>
                                	&nbsp;
                            	</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  value="#{cc.attrs.bill.netTotal-(cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.paidByCreditCompany)}"  >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>
                            	</td>
                        	</tr>


                    	</h:panelGroup>-->



                	</table>



                	<p:spacer height="50px"></p:spacer>
                	<h:outputLabel value="Prepared By : #{cc.attrs.bill.creater.code}" style="margin-left: 30%; text-decoration: overline;">
                	</h:outputLabel>
                	<h:outputLabel value="Cashier :" style="margin-left: 25%; text-decoration: overline;">
                	</h:outputLabel>
                	<h:outputLabel value="Patient/Guardian" style="margin-left: 10%; text-decoration: overline;">
                	</h:outputLabel>


            	</div>
<!--            	<div style="position: absolute;
                 	left: 0%;
                 	bottom:  3%;                                                         	 
                 	font-size:10px!important;" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}" >
                	<h:outputLabel value="#{cc.attrs.bill.netTotal-cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.creditPaidAmount}" >
                    	<f:convertNumber pattern="******0.00" />
                	</h:outputLabel>
            	</div>
            	<div style="position: absolute;
                 	left: 50%;
                 	bottom:  3%;
                 	font-size:10px!important;" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}" >
                	<h:outputLabel  value="#{cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.creditPaidAmount}" rendered="#{cc.attrs.bill.paidAmount !=0}" >
                    	<f:convertNumber pattern="******0.00" />
                	</h:outputLabel>
            	</div>-->


        	</p:panel>
    	</div>
	</cc:implementation>
</html>
